package demo.practice.backtrack;

public class P518 {

    public static void main(String[] args) {
        P518 p518 = new P518();
        p518.change(5, new int[]{1, 2, 5});
    }


    public int change(int amount, int[] coins) {

        int[] dp = new int[amount + 1];
        dp[0] = 1;//代表

        for (int i = 0; i < dp.length; i++) {
            for (int c : coins) {
                //int dpindex = i + c;
                //if (dpindex < dp.length)
                dp[i] = dp[i] + dp[i-c];
            }
        }
        return dp[amount];
    }
}
